<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新商城 - 首页</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
    <header class="bg-white shadow-md">
        <div class="container mx-auto px-4 py-6 flex justify-between items-center">
            <div class="text-2xl font-bold text-blue-600">新商城</div>
            <div class="flex space-x-4">
                <button id="userLoginBtn" class="px-6 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition">
                    <i class="fa fa-user mr-2"></i>用户登录
                </button>
                <button id="merchantLoginBtn" class="px-6 py-2 bg-green-500 text-white rounded-md hover:bg-green-600 transition">
                    <i class="fa fa-store mr-2"></i>商家登录
                </button>
            </div>
        </div>
    </header>

    <main class="container mx-auto px-4 py-12">
        <div class="text-center mb-12">
            <h1 class="text-4xl font-bold mb-4">欢迎来到新商城</h1>
            <p class="text-gray-600 text-lg">选择您的角色开始使用</p>
        </div>

        <div class="grid grid-cols-2 gap-8 max-w-4xl mx-auto">
            <div class="bg-white rounded-lg shadow-lg p-8 text-center hover:shadow-xl transition transform hover:-translate-y-1">
                <div class="w-20 h-20 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <i class="fa fa-user text-4xl text-blue-600"></i>
                </div>
                <h2 class="text-2xl font-bold mb-4">普通用户</h2>
                <p class="text-gray-600 mb-6">浏览商品、购买商品、管理订单</p>
                <div class="flex flex-col space-y-3">
                    <button id="userRegisterBtn" class="px-6 py-3 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition">
                        <i class="fa fa-user-plus mr-2"></i>用户注册
                    </button>
                    <button id="goUserLoginBtn" class="px-6 py-3 border border-blue-500 text-blue-600 rounded-md hover:bg-blue-50 transition">
                        <i class="fa fa-sign-in mr-2"></i>已有账号？登录
                    </button>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow-lg p-8 text-center hover:shadow-xl transition transform hover:-translate-y-1">
                <div class="w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <i class="fa fa-store text-4xl text-green-600"></i>
                </div>
                <h2 class="text-2xl font-bold mb-4">商家用户</h2>
                <p class="text-gray-600 mb-6">管理店铺、上架商品、处理订单</p>
                <div class="flex flex-col space-y-3">
                    <button id="merchantRegisterBtn" class="px-6 py-3 bg-green-500 text-white rounded-md hover:bg-green-600 transition">
                        <i class="fa fa-user-plus mr-2"></i>商家注册
                    </button>
                    <button id="goMerchantLoginBtn" class="px-6 py-3 border border-green-500 text-green-600 rounded-md hover:bg-green-50 transition">
                        <i class="fa fa-sign-in mr-2"></i>已有账号？登录
                    </button>
                </div>
            </div>

            <div class="bg-white rounded-lg shadow-lg p-8 text-center hover:shadow-xl transition transform hover:-translate-y-1">
                <div class="w-20 h-20 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-6">
                    <i class="fa fa-cogs text-4xl text-purple-600"></i>
                </div>
                <h2 class="text-2xl font-bold mb-4">系统用户</h2>
                <p class="text-gray-600 mb-6">管理用户、管理系统配置</p>
                <div class="flex flex-col space-y-3">
                    <button id="goSystemLoginBtn" class="px-6 py-3 border border-purple-500 text-purple-600 rounded-md hover:bg-purple-50 transition">
                        <i class="fa fa-sign-in mr-2"></i>系统用户登录
                    </button>
                </div>
            </div>
        </div>
    </main>

    <footer class="bg-gray-800 text-white py-8 mt-16">
        <div class="container mx-auto px-4 text-center">
            <p>© 2025 新商城 版权所有</p>
        </div>
    </footer>

    <script>
        // 页面跳转逻辑
        document.getElementById('userLoginBtn').addEventListener('click', () => {
            window.location.href = 'user-login.html';
        });
        
        document.getElementById('merchantLoginBtn').addEventListener('click', () => {
            window.location.href = 'merchant-login.html';
        });
        
        document.getElementById('userRegisterBtn').addEventListener('click', () => {
            window.location.href = 'user-register.html';
        });
        
        document.getElementById('merchantRegisterBtn').addEventListener('click', () => {
            window.location.href = 'merchant-register.html';
        });
        
        document.getElementById('goUserLoginBtn').addEventListener('click', () => {
            window.location.href = 'user-login.html';
        });
        
        document.getElementById('goMerchantLoginBtn').addEventListener('click', () => {
            window.location.href = 'merchant-login.html';
        });

        document.getElementById('goSystemLoginBtn').addEventListener('click', () => {
            window.location.href = 'system-login.html';
        });

        // 检查是否已登录
        window.addEventListener('DOMContentLoaded', () => {
            const user = localStorage.getItem('user');
            const merchant = localStorage.getItem('merchant');
            const systemUser = localStorage.getItem('systemUser'); // 新增系统用户检查

            if (user) {
                window.location.href = 'user-home.html';
            } else if (merchant) {
                window.location.href = 'merchant-home.html';
            }else if (systemUser) { // 新增系统用户跳转
                window.location.href = 'system-home.html';
            }
        });
    </script>
</body>
</html>